﻿Imports ReporteLista
Imports utileria

Partial Class Reportes_Reporte_Tienta
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        Dim utiles As New utileria
        Dim ReporteTienta As New ReporteTienta
        Dim SqlDbDataSource As New DataDynamics.ActiveReports.DataSources.SqlDBDataSource

        Dim sSQLBasic = "SELECT AnimalId, sexo, numero, letra, ano, nombre, pelaje1," & _
            "(SELECT catnom from catalogo_general where cattip = 'H' And catcve= hierro) AS hierro," & _
            "(SELECT catnom from catalogo_general where cattip = 'E' And catcve= encaste) AS encaste," & _
            "(SELECT catnom from catalogo_general where cattip = 'P' And catcve= propiedad) AS propiedad," & _
            "(SELECT catnom from catalogo_general where cattip = 'U' And catcve= ubicacion) AS ubicacion," & _
            " photo,estatus,  fechanac," & _
                            " porcien_cs, no_padre, ltra_padre, ano_padre, id_padre, hie_padre," & _
                            " ano_madre, ltra_madre, no_madre, id_madre, hie_madre, abuelo_mat," & _
                            " tienta_ac, tienta_ap, lidia_ap, lidia_ac, estatus, fechabaja, " & _
                            "tienta_fecha, tienta_torero, hijos, hijas FROM animal "
        Dim sWhere As String = ""

        If Not IsNothing(Session("filtro")) Then
            sWhere = utiles.sWhereFiltro(Session("filtro"))
        End If

        If Not sWhere = "" Then
            Dim sConexion = ConfigurationManager.ConnectionStrings("GanaderiaConnectionString").ConnectionString
            SqlDbDataSource.ConnectionString = sConexion
            SqlDbDataSource.SQL = sSQLBasic & sWhere
            ReporteTienta.DataSource = SqlDbDataSource
            WebViewer1.Report = ReporteTienta
        End If
        

    End Sub
End Class
